package com.example.kotlin.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import com.example.kotlin.R
import com.example.kotlin.util.SimpleWorker
import kotlinx.android.synthetic.main.activity_first.doWorkBtn
import kotlinx.android.synthetic.main.activity_first.toCamera
import kotlinx.android.synthetic.main.activity_first.toFileStore
import kotlinx.android.synthetic.main.activity_first.toForeNotification
import kotlinx.android.synthetic.main.activity_first.toNotification
import kotlinx.android.synthetic.main.activity_first.toRoom
import kotlinx.android.synthetic.main.activity_first.toRuntime
import kotlinx.android.synthetic.main.activity_first.toSQL
import kotlinx.android.synthetic.main.activity_first.toSecondActivity
import kotlinx.android.synthetic.main.activity_first.toService
import kotlinx.android.synthetic.main.activity_first.toThirdActivity
import kotlinx.android.synthetic.main.activity_first.tocontacts
import kotlinx.android.synthetic.main.activity_first.tologinout

class FirstActivity : BaseActivity(), View.OnClickListener {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_first)

        toSecondActivity.setOnClickListener(this)
        toThirdActivity.setOnClickListener(this)
        tologinout.setOnClickListener(this)
        toFileStore.setOnClickListener(this)
        toSQL.setOnClickListener(this)
        toRuntime.setOnClickListener(this)
        tocontacts.setOnClickListener(this)
        toNotification.setOnClickListener(this)
        toCamera.setOnClickListener(this)
        toService.setOnClickListener(this)
        toRoom.setOnClickListener(this)
        toForeNotification.setOnClickListener(this)
        doWorkBtn.setOnClickListener(this)
    }

    override fun onClick(view: View?) {
        when(view){
            toSecondActivity->startActivity(Intent(this, SecondActivity::class.java))
            toThirdActivity->startActivity(Intent(this, ThirdActivity::class.java))
            tologinout->{
                val intent=Intent("com.example.kotlin.FORCE_OFFLINE")
                sendBroadcast(intent)
            }
            toFileStore->startActivity(Intent(this,FileStoreActivity::class.java))
            toSQL-> startActivity(Intent(this,SQLActivity::class.java))
            toRuntime-> startActivity(Intent(this,RuntimeActivity::class.java))
            tocontacts->startActivity(Intent(this,ContentProvide1Activity::class.java))
            toNotification->startActivity(Intent(this,NotificationActivity::class.java))
            toCamera->startActivity(Intent(this,CameraActivity::class.java))
            toService->startActivity(Intent(this,ServiceActivity::class.java))
            toRoom->startActivity(Intent(this,RoomActivity::class.java))
            toForeNotification->startActivity(Intent(this,MainActivity::class.java))
            doWorkBtn->{
                val request = OneTimeWorkRequest.Builder(SimpleWorker::class.java).build()
                WorkManager.getInstance(this).enqueue(request)
            }
        }
    }
}